import { reactive } from 'vue'
import { Form } from 'ant-design-vue';

const useForm = Form.useForm;

function useFormValidator(formState: any) {
  const _formRules = reactive({
    mobilePhone: [{ required: true, message: '请输入账号' }, { pattern: /^[1][0-9]{10}$/, message: '请输入正确的手机号' }],
    password: [{ required: true, message: '请输入密码' }, { pattern: /^[\x21-\x7e]{6,14}$/, message: '6-14位密码' }],
  })
  const { resetFields, validate, validateInfos } = useForm(formState, _formRules, {
    onValidate: (...args) => { },
  });
  return {
    // formRules,
    validateInfos,
    validate
  }
}

export {
  useFormValidator
}